#include<bits/stdc++.h>
#define int long long
using namespace std;

const int N = 1e5 + 10;
double a[N];

map<int, int>mp;

signed main() {
	int n;
	cin >> n;
	for(int i = 1; i <= n; ++ i ) {
		cin >> a[i];
	}
	int x, y;
	double ret;
	while(cin >> x >> y) {
		if(x == 0) {
			break;
		}
		mp[x] += y;
		ret += a[x] * 1.0 * y;
	}
	for(int i = 1; i <= n; ++ i ) {
		cout << mp[i] << endl;
	}
	printf("%.2lf\n", ret);
	return 0;
}

